<?php

class Item extends AppModel {

    var $name = 'Item';
    var $uses = array('Article','Item'); 
    var $displayField = 'id';
    var $validate = array(
        'sale_amount' => array(
            'numeric' => array(
                'rule' => array('numeric'),
                'message' => 'Solo números',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
            array(
                'rule' => array('comparison', '>', 0),
                'message' => 'Solo valores positivos.'
            ),
        ),
        'article_id' => array(
            'numeric' => array(
                'rule' => array('numeric'),
                'message' => 'Solo números',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'sale_id' => array(
            'numeric' => array(
                'rule' => array('numeric'),
                'message' => 'Solo números',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
    );
    //The Associations below have been created with all possible keys, those that are not needed can be removed

    var $belongsTo = array(
        'Article' => array(
            'className' => 'Article',
            'foreignKey' => 'article_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'Sale' => array(
            'className' => 'Sale',
            'foreignKey' => 'sale_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        )
    );

}
